package xsdcl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class TreeEdgeUtils
{
	private static List<TreeEdge> edgeList = new ArrayList<TreeEdge>();

	public static TreeEdge FindEdgeByName(String edgeName)
	{
		for (TreeEdge edge:edgeList)
		{
			if (edge.getName().equalsIgnoreCase(edgeName))
				return edge;
		}
		return null;
	}
	// public static TreeEdge FindEdgeByNodes(TreeNode parent, TreeNode child)
	// {
	// for (TreeEdge edge : edgeList)
	// {
	// if (edge.getParentNode().equals(parent)
	// && edge.getChildNode().equals(child))
	// {
	// return edge;
	// }
	// }
	// return null;
	// }

	public static boolean addEdge(TreeEdge edge)
	{
		if (!IsExisted(edge))
		{
			edgeList.add(edge);
			//System.out.println("addEdge: "+ edge.getName());
			return true;
		}
		return false;
	}

	public static boolean IsExisted(TreeEdge newEdge)
	{
		for (TreeEdge edge : edgeList)
		{
			if (edge.equals(newEdge))
				return true;
		}

		return false;
	}

	public static List<TreeEdge> getEdgeList()
	{
		return edgeList;
	}
	
	
}
